local skel = fk.CreateSkill {
  name = "emo__feixue",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["emo__feixue"] = "沸血",
  [":emo__feixue"] = "锁定技，你每次至多摸一张牌。每当你摸牌后，若不为【杀】，你摸一张牌；若为【杀】，你须无次数距离限制地使用之。",

  ["#emo__feixue-slash"] = "沸血：请使用你摸的【杀】！",
}

skel:addEffect(fk.BeforeDrawCard, {
  anim_type = "negative",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and data.num > 0
  end,
  on_use = function (self, event, target, player, data)
    data.num = 1
  end,
})

skel:addEffect(fk.AfterCardsMove, {
  anim_type = "drawcard",
  can_trigger = function (self, event, target, player, data)
    if not player:hasSkill(skel.name) then return false end
    for _, move in ipairs(data) do
      if move.toArea == Card.PlayerHand and move.moveReason == fk.ReasonDraw and move.to == player then
        if #move.moveInfo > 0 then return true end
      end
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local slash = {}
    player:filterHandcards()
    for _, move in ipairs(data) do
      if move.toArea == Card.PlayerHand and move.moveReason == fk.ReasonDraw and move.to == player then
        for _, info in ipairs(move.moveInfo) do
          if table.contains(player.player_cards[Player.Hand], info.cardId) then
            if Fk:getCardById(info.cardId).trueName == "slash" then
              table.insert(slash, info.cardId)
            end
          end
        end
      end
    end
    if #slash == 0 then
      player:drawCards(1, skel.name)
    else
      room:askToUseRealCard(player, {
        skill_name = skel.name, skip = false, pattern = slash, cancelable = false,
        prompt = "#emo__feixue-slash",
        extra_data = {
          bypass_distances = true, bypass_times = true,
        }
      })
    end
  end,
})

return skel
